<template>
  <div>
    <van-search v-model="value" placeholder="请输入搜索关键词" />
    <van-tabs v-model="active" style="overflow: auto">
      <van-tab title="2019新款">
        <div
          v-for="item in list"
          :key="item.id"
          class="zcy_item"
          @click="add(item.id)"
        >
          <img :src="item.img" alt="" />
          <h3>{{ item.content }}</h3>
          <p>
            <span>{{ "￥" + item.price }}</span>
            <span>{{ "已售" + item.num + "件" }}</span>
          </p>
        </div>
      </van-tab>
      <van-tab title="小绅士">
        <div
          v-for="item in list"
          :key="item.id"
          class="zcy_item"
          @click="add(item.id)"
        >
          <img :src="item.img" alt="" />
          <h3>{{ item.content }}</h3>
          <p>
            <span>{{ "￥" + item.price }}</span>
            <span>{{ "已售" + item.num + "件" }}</span>
          </p>
        </div>
      </van-tab>
      <van-tab title="小公主">
        <div
          v-for="item in list"
          :key="item.id"
          class="zcy_item"
          @click="add(item.id)"
        >
          <img :src="item.img" alt="" />
          <h3>{{ item.content }}</h3>
          <p>
            <span>{{ "￥" + item.price }}</span>
            <span>{{ "已售" + item.num + "件" }}</span>
          </p>
        </div>
      </van-tab>
      <van-tab title="玩具">
        <div
          v-for="item in list"
          :key="item.id"
          class="zcy_item"
          @click="add(item.id)"
        >
          <img :src="item.img" alt="" />
          <h3>{{ item.content }}</h3>
          <p>
            <span>{{ "￥" + item.price }}</span>
            <span>{{ "已售" + item.num + "件" }}</span>
          </p>
        </div>
      </van-tab>
    </van-tabs>
    <van-tabbar v-model="activev">
      <van-tabbar-item icon="home-o">商城</van-tabbar-item>
      <van-tabbar-item icon="apps-o">分类</van-tabbar-item>
      <van-tabbar-item icon="shopping-cart-o">购物车</van-tabbar-item>
      <van-tabbar-item icon="friends-o">用户中心</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      active: 0,
      activev: 0,
      value: "",
    };
  },
  mounted() {
    this.$axios.get("/list.json").then((res) => {
      console.log(res);
      this.list = res.data;
    });
  },
  methods: {
    add(id) {
      this.$router.push({ path: "/data", query: { id } });
    },
  },
};
</script>
<style lang="scss" scoped>
.zcy_item img {
  width: 100%;
}
.zcy_item {
  width: 50%;
  float: left;
  box-sizing: border-box;
  padding: 0 5px;
  h3 {
    margin: 5px 0;
  }
  p {
    margin: 0;
  }
}
</style>